﻿using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Effects;

namespace Black.SurfaceToolkit.Effects
{
    /// <summary>
    /// Greyscale Effect
    /// </summary>
    public class GreyscaleEffect : ShaderEffect
    {
        #region Propriétées de dépendances

        public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(GreyscaleEffect), 0);

        #endregion

        #region Accesseurs

        /// <summary>
        /// Affecte ou retourne la propriété Input du Shader
        /// </summary>
        public Brush Input
        {
            get
            {
                return ((Brush)this.GetValue(GreyscaleEffect.InputProperty));
            }
            set
            {
                this.SetValue(GreyscaleEffect.InputProperty, value);
            }
        }

        #endregion

        #region Variables statiques

        private static readonly PixelShader _PixelShader = new PixelShader();

        #endregion

        #region Constructeurs

        /// <summary>
        /// Constructeur statique 
        /// </summary>
        static GreyscaleEffect()
        {
            GreyscaleEffect._PixelShader.UriSource = new Uri("pack://application:,,,/Black.SurfaceToolkit;component/Effects/Shaders/Greyscale.ps");
        }

        /// <summary>
        /// Constructeur de la classe
        /// </summary>
        public GreyscaleEffect()
        {
            this.PixelShader = GreyscaleEffect._PixelShader;
            this.UpdateShaderValue(GreyscaleEffect.InputProperty);
        }

        #endregion
    }
}
